﻿/// <summary>
/// FileName: ConstantExpression.cs
/// Author: Jiang Xiaolong
/// Created Time: 2015.05.12
/// Version: 1.0
/// Company: Sunnytech
/// Function: 变量表达式；
///
/// Changed By:
/// Modification Time:
/// Discription:
/// </summary>
using System;
using Expression.api;

namespace Expression.impl
{
	public class VariableExpression : ExpressionTree
	{
		public Type ExpType
		{
			get { return _value.ExpType; }
			set { }
		}

		private Variable _value = null;

		public VariableExpression(Variable value)
		{
			this._value = value;
		}

		public object Evaluate()
		{
			return _value.GetValue();
		}

		public override string ToString()
		{
			return _value.GetName();
		}

        public ExpressionTree Clone ()
        {
            VariableExpression expClone = new VariableExpression(_value);
            expClone.ExpType = this.ExpType;
            return expClone;
        }
	}
}
